<?php
/**
 * 用户升级订单列表
 * author itholiday@126.com
 */
global $_W, $_GPC;
load()->func('tpl');
$html_title = $_W['current_module']['title'];
$op = !empty($_GPC['op']) ? $_GPC['op'] : 'list';
//$op =$_GPC['op'];
//页面显示条数
$pagesize = 20;
$page = max(1, $_GPC['page']);
$start = ($page - 1 ) * $pagesize;

$where = "A.id>0";


$start_time = isset($_GPC['start_time']) && !empty($_GPC['start_time']) ? strtotime($_GPC['start_time']) : '';
$end_time = isset($_GPC['end_time']) && !empty($_GPC['end_time']) ? strtotime($_GPC['end_time']) : '';
$order_sn = isset($_GPC['order_sn']) && !empty($_GPC['order_sn']) ? input('order_sn') : '';
$keyword = isset($_GPC['keyword']) && !empty($_GPC['keyword']) ? input('keyword') : '';
$paytype = isset($_GPC['paytype']) && !empty($_GPC['paytype']) ? input('paytype') : '';
$is_true = isset($_GPC['is_true']) && !empty($_GPC['is_true']) ? input('is_true') : '';

if (!empty($is_true)){
    $where .= " and A.is_true like '%$is_true%' ";
}

if (!empty($paytype)){
    $where .= " and A.paytype='$paytype' ";
}

if (!empty($order_sn)){
    $where .= " and A.order_sn like '%$order_sn%' ";
}

if (!empty($keyword)){
    $where .= " and (A.user_id='$keyword' or B.mobile='$keyword' or B.truename='%$keyword%') ";
}

if (!empty($start_time) && !empty($end_time)){
    $where .= " and A.paytime>=$start_time and A.paytime<=$end_time ";
} else {
    if (!empty($start_time)){
        $where .= " and A.paytime >= $start_time ";
    }
    if (!empty($end_time)){
        $where .= " and A.paytime <= $end_time ";
    }
}

if($op == "list" || $op == " "){
    $total = pdo_fetchcolumn('SELECT COUNT(*) AS `number` FROM ' . tablename('yq_haircircle_upgrade_order') . 'A left join ims_yq_haircircle_users B on A.user_id=B.id WHERE ' . $where);
    $pager = getPageHTML($total,$page,$pagesize);

    $sql = "select A.*,B.mobile from ims_yq_haircircle_upgrade_order A left join ims_yq_haircircle_users B on A.user_id=B.id where $where order by A.id desc,A.paytime desc limit $start,$pagesize";
    $list = pdo_fetchall($sql);
    include $this->template('web/member_upgrade_list');
    exit;
}
